/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.header.OrganizationHeader;
import java.text.ParseException;

/**
 * The OrganizationHeader conveys the name of the organization to which the
 * entity issuing the Request or Response belongs. It may be used by client
 * software to filter calls.
 *
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class OrganizationHeaderImpl extends HeaderBase implements OrganizationHeader {
    private String organization;

    private static final OrganizationHeaderParser  parser = new OrganizationHeaderParser();

    public OrganizationHeaderImpl() {
        super(OrganizationHeader.NAME);
    }

    OrganizationHeaderImpl(byte[] data, int start, int end) {
        super(OrganizationHeader.NAME, data, start, end);
    }

    public Object clone() {
        final OrganizationHeaderImpl header = new OrganizationHeaderImpl();
        header.cloneBase(this);
        if (parsed) {
            header.organization = this.organization;
        }
        return header;
    }

    protected HeaderParser getParser() {
        return parser;
    }

    protected String getValueAsString() {
        return organization;
    }

    /**
     * Sets the organization value of the OrganizationHeader to the
     * organization parameter supplied.
     *
     * @param organization the new string organization value
     * @throws java.text.ParseException which signals that an error has been reached
     *                                  unexpectedly while parsing the organization value.
     */

    public void setOrganization(String organization) throws ParseException {
        parse();
        this.organization = organization;
        invalidateHeaderData();
    }

    /**
     * Gets the organization value of OrganizationHeader.
     *
     * @return organization of OrganizationHeader
     */

    public String getOrganization() {
        parse();
        return this.organization;
    }
}
/*
 * $Log$
 */